package com.bw.z.mvp.model.entity;

import com.bw.z.utils.LogUtils;
import com.google.gson.Gson;

import org.json.JSONArray;
import org.json.JSONException;

import java.util.ArrayList;
import java.util.List;

public class RecommendEntity extends BaseEntity {
    public String values;

    public List<Values> getValues() {
        if (values == null)
            return null;
        List<Values> list = new ArrayList<>();
        try {
            JSONArray jay = new JSONArray(values);
            for (int i = 0; i < jay.length(); i++) {
                String str = jay.getString(i);
                LogUtils.show("RecommendEntity:values:" + str);
                Values values = new Gson().fromJson(str, Values.class);
                list.add(values);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }

        return list;
    }

    public static class Values {
        public int news_type;
        public String news_author;
        public String news_value;
        public String news_title;
        public String news_url;
        public long news_time;
        public long author_id;
        public long channel_id;
        public long news_id;
        public List<MediaValues> medias;

        public List<MediaValues> getMedias() {
//            if (medias == null)
//                return null;
//            List<MediaValues> list = new ArrayList<>();
//            try {
//                JSONArray jay = new JSONArray(medias);
//                for (int i =0;i < jay.length();i ++){
//                    String media = jay.getString(i);
//                    MediaValues mediaValues = new Gson().fromJson(media,MediaValues.class);
//                    list.add(mediaValues);
//                }
//            } catch (JSONException e) {
//                e.printStackTrace();
//            }
            return medias;
        }

    }

    public static class MediaValues {
        public int media_type;
        public long media_id;
        public String media_url;
    }
}
